const express = require('express');
const recipeRoute = require('./recipe.route');
const dietRecordRoute = require('./dietRecord.route');
const nutritionRoute = require('./nutrition.route');
const { auth, authorize } = require('../../middleware/auth');
const validate = require('../../middleware/validate');
const adminValidation = require('../../validators/admin.validation');
const { adminController } = require('../../controllers');

const router = express.Router();

// 登录路由 - 不需要认证
router.post('/login', validate(adminValidation.login), adminController.loginAdmin);

// 需要认证的路由
const routes = [
  {
    path: '/recipes',
    route: recipeRoute,
  },
  {
    path: '/diet-records',
    route: dietRecordRoute,
  },
  {
    path: '/nutrition',
    route: nutritionRoute,
  },
];

routes.forEach((route) => {
  router.use(route.path, route.route);
});

module.exports = router;